<?php

/*use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\Reminders\RemindableInterface;*/

class User extends Record { //implements UserInterface, RemindableInterface {

	//use UserTrait, RemindableTrait;

	/**
	 * The database table used by the model.
	 *
	 * @var string
	 */
	protected $table = 'users'; //'users';

	/**
	 * The attributes excluded from the model's JSON form.
	 *
	 * @var array
	 */
	//protected $hidden = array('password', 'remember_token');
	
	/*public function url(){
		return URL::action('HomeController@showNewsDetail', [
			'id'=> $this->id,
			'title'=> $this->sefFormat($this->name),
		]);
	}*/
	public function hashPassword( $password ) {
		return hash('sha256', $password );
	}
	
	public function scopeUsername($query,$username) {
		return $query->where('username', '=', $username );
	}
	public function scopePassword($query,$password) {
		return $query->where('password', '=', self::hashPassword($password) );
	}
	public function scopeRole($query,$role) {
		return $query->where('user_role_id', '=', $role );
	}

}